package com.zw.pdm.module.system.controller;

import com.zw.pdm.base.BaseController;
import com.zw.pdm.common.JsonResult;
import com.zw.pdm.module.system.service.IndexService;
import com.zw.pdm.module.system.service.UserService;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Description:
 *
 * @Author: China.sgl
 * @Date: 2020/7/30 9:42
 */
@Controller
@SuppressWarnings("all")
public class IndexController extends BaseController {

    @Autowired
    private UserService userService;
    @Autowired
    private IndexService indexService;

    @GetMapping("/index")
    public String index(Model model) {
        model.addAttribute("issueTaskCount", indexService.getIssueTaskCount());
        model.addAttribute("checkProCount", indexService.getCheckProCount());
        model.addAttribute("saveProCount", indexService.getSaveProCount());
        model.addAttribute("checkProOutCount", indexService.getCheckProOutCount());
        /** 未提交制作件清单数量*/
        model.addAttribute("notSubmitMakeCount", indexService.getNotSubmitMakeCount());
        /** 未审核制作件清单数量*/
        model.addAttribute("notCheckMakeCount", indexService.getNotCheckMakeCount());
        /** 未提交图纸数量*/
        model.addAttribute("notSubmitDrawtCount", indexService.getNotSubmitDrawtCount());
        /** 未审核图纸数量*/
        model.addAttribute("notCheckDrawCount", indexService.getNotCheckDrawCount());
        /**未接收制作件清单数量*/
        model.addAttribute("releaseCount", indexService.getReleaseCount());
        /** 未提交存档清单数量*/
        model.addAttribute("notSubmitFileCount", indexService.getNotSubmitFileCount());
        /** 未审核存档清单数量*/
        model.addAttribute("notCheckFileCount", indexService.getNotCheckFileCount());
        /** 未下发存档清单数量*/
        model.addAttribute("notLuessFileCount", indexService.getNotLuessFileCount());
        /** 未签收存档清单数量*/
        model.addAttribute("notSignFileCount", indexService.getNotSignFileCount());
        /** 未审核提报计划数量 */
        model.addAttribute("notCheckReportCount", indexService.getNotCheckReportCount());
        /**工艺变更提醒未处理数量*/
        model.addAttribute("notCardChangCount",indexService.getNotCardChangCount());
        /**工艺卡待提交数量*/
        model.addAttribute("notCreateCodeOneCount",indexService.getNotCreateCodeOne());

        return "index";
    }

    /**
     * 修改密码
     *
     * @param pwd 新密码
     * @return json
     */
    @ResponseBody
    @PostMapping("/update/user/pwd")
    @RequiresAuthentication
    public JsonResult updatePwd(String pwd) {
        return isNotNull(userService.updateUserPassword(pwd));
    }

}
